package com.doit.demo02;

public class Test_String_T {
    public static void main(String[] args) {
        char [] as = {'a','b','c'};
        String s = new String(as);
        System.out.println(s);
        String s2 = new String (as,1,1);//将as转换为字符串,从第1个开始,共转换1个
        System.out.println(s2);

        System.out.println("-----------------------------");
        byte [] b = {65,66,67,97};
        String s3 = new String(b);//解码
        System.out.println(s3);
        String s4 = new String (b,1,3);//将b转换为字符串,从索引为1的开始,共转换3个
        System.out.println(s4);

        System.out.println("----------------------");
        String s5 = "abcd";
        char[] chars = s5.toCharArray();
        System.out.println(chars);
        byte[] bytes = s5.getBytes();
        for (int i = 0; i < bytes.length; i++) {
            System.out.println(bytes[i]);
        }
        int[] a = {97,98,99};
        String aa = new String (a,0,3);

        System.out.println(aa);

        System.out.println("================");
        String s6 = "I love niangmen";
        String s1 = s6.toUpperCase();
        System.out.println(s1);
        String s7 = s6.toLowerCase();
        System.out.println(s7);

        boolean i = s6.startsWith("I");
        System.out.println(i);//判断开头是否以I开始

        boolean niangmen = s6.endsWith("niangmen");
        System.out.println(niangmen);//判断结尾是否以niangmen结尾

        //endwith比较常用在判断文件后缀
        String s8 = ".Java";
        System.out.println(s8.toUpperCase().endsWith(".JAVA"));//先转为大写,后判断
        System.out.println(s8.toLowerCase().endsWith(".java"));//先转为小写,后判断
        System.out.println("++++++++++++++++++++++++++++++");

    }
}
